home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / examples / cache-packages.py < prev    next >
Encoding:
Python Source  |  2009-03-30  |  497 b   |  23 lines

  1. #!/usr/bin/python
  2. """Example for packages. Print all essential and important packages"""
  3.  
  4. import apt_pkg
  5.  
  6.  
  7. def main():
  8.     """Main."""
  9.     apt_pkg.InitConfig()
  10.     apt_pkg.InitSystem()
  11.     cache = apt_pkg.GetCache()
  12.     print "Essential packages:"
  13.     for pkg in cache.Packages:
  14.         if pkg.Essential:
  15.             print " ", pkg.Name
  16.     print "Important packages:"
  17.     for pkg in cache.Packages:
  18.         if pkg.Important:
  19.             print " ", pkg.Name
  20.  
  21. if __name__ == "__main__":
  22.     main()
  23.